
(function(){
function huabu(id,x){
			var w=id.split("=");
			this.k=w[0];
			this.ID=id;
			switch(w[0]){  //目前只支持使用ID获取元素 和定义2d类型
				case "id":var a;a=document.getElementById(w[1]).getContext("2d");this.id=a;if(x=="*"){ return a};
				break;
				default:this.id=id;if(x=="*"){return id;}
				}
			}

	huabu.prototype.类型=function(d){
		if(this.k=="id"){
			return this.id.getContext(d);
			}else{
				for(var i=0;i<this.id.length;i++){
					var a=[];
					a.push(this.id[i].getContext(d));
					}
					return a;
				}
		}

	huabu.prototype.填充_矩形=function(a,b,c,d){//++
		if(this.k=="id"){
			this.id.fillRect(a,b,c,d);
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].fillRect(a,b,c,d);
					}
				}
		}
		
	huabu.prototype.填充_样式=function(d){//++
		if(this.k=="id"){
			this.id.fillStyle=d;
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].fillStyle=d;
					}
				}
	}	
	
	huabu.prototype.矩形=function(x, y, width, height){//++
		if(this.k=="id"){
			this.id.strokeRect(x, y, width, height);
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].strokeRect(x, y, width, height);
					}
				}
	}	
	
	huabu.prototype.清除_矩形=function(x,y,width,height){//++
		if(this.k=="id"){
			this.id.clearRect(x,y,width,height);
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].clearRect(x,y,width,height);
					}
				}
	}	
	
		
huabu.prototype.开始画路径=function(){//++
		if(this.k=="id"){
			this.id.beginPath();
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].beginPath();
					}
				}
	}	
	
	huabu.prototype.移动到=function(x,y){//++
		if(this.k=="id"){
			this.id.moveTo(x,y);
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].moveTo(x,y);
					}
				}
	}	
	
huabu.prototype.画线=function(x, y){//++
		if(this.k=="id"){
			this.id.lineTo(x,y)
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].lineTo(x,y)
					}
				}
	}	
huabu.prototype.关闭_路径=function(){
		if(this.k=="id"){
			this.id.closePath();
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].closePath();
					}
				}
	}	

huabu.prototype.画=function(){//++
		if(this.k=="id"){
			this.id.stroke();
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].stroke();
					}
				}
	}	

huabu.prototype.填充=function(){
		if(this.k=="id"){
			this.id.fill();
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].fill();
					}
				}
	}	
huabu.prototype.弧=function(x, y, radius, startAngle, endAngle, anticlockwise){//++
		if(this.k=="id"){
			this.id.arc(x, y, radius, startAngle, endAngle, anticlockwise);
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].arc(x, y, radius, startAngle, endAngle, anticlockwise);
					}
				}
	}	

huabu.prototype.画弧=function(x1, y1, x2, y2, radius){//++
		if(this.k=="id"){
			this.id.arcTo(x1, y1, x2, y2, radius)
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].arcTo(x1, y1, x2, y2, radius)
					}
				}
	}	

huabu.prototype.二次贝兹曲线=function(a,b,c,d){//++
		if(this.k=="id"){
			this.id.quadraticCurveTo(a,b,c,d);
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].quadraticCurveTo(a,b,c,d);
					}
				}
	}	

huabu.prototype.三次贝兹曲线=function(a,b,c,d,e,f){//++
		if(this.k=="id"){
			this.id.bezierCurveTo(a,b,c,d,e,f);
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].bezierCurveTo(a,b,c,d,e,f);
					}
				}
	}	

huabu.prototype.画_样式=function(d){////
		if(this.k=="id"){
			this.id.strokeStyle=d;
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].strokeStyle=d;
					}
				}
	}	

huabu.prototype.透明度=function(d){//++
		if(this.k=="id"){
			this.id.globalAlpha=d;
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].globalAlpha=d;
					}
				}
	}
	
//new Path2D();



huabu.prototype.线宽=function(d){////
		if(this.k=="id"){
			this.id.lineWidth=d;
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].lineWidth=d;
					}
				}
	}
	
		

huabu.prototype.线端点类型=function(d){////butt round square
		if(this.k=="id"){
			this.id.lineCap =d;
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].lineCap =d;
					}
				}
	}

huabu.prototype.填充_文本=function(text, x, y ,maxWidth){
		if(this.k=="id"){
			this.id.fillText(text, x, y ,maxWidth);
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].fillText(text, x, y ,maxWidth);
					}
				}
	}
	
huabu.prototype.绘制_文本=function(text, x, y , maxWidth){//++
		if(this.k=="id"){
			this.id.strokeText(text, x, y , maxWidth);
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].strokeText(text, x, y , maxWidth);
					}
				}
	}


huabu.prototype.字体=function(d){
		if(this.k=="id"){
			this.id.font=d;
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].font=d;
					}
				}
	}
	
huabu.prototype.文本对齐=function(d){
		if(this.k=="id"){
			this.id.textAlign=d;
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].textAlign=d;
					}
				}
	}
huabu.prototype.文本基线对齐=function(d){
		if(this.k=="id"){
			this.id.textBaseline=d;
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].textBaseline=d;
					}
				}
	}

huabu.prototype.文本方向=function(d){
		if(this.k=="id"){
			this.id.direction=d;
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].direction=d;
					}
				}
	}
	
huabu.prototype.绘制图像=function(image, x, y, width, height){
		if(this.k=="id"){
			this.id.drawImage(image, x, y, width, height)
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].drawImage(image, x, y, width, height)
					}
				}
	}
	
huabu.prototype.图像切片=function(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight){
		if(this.k=="id"){
			this.id.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
					}
				}
	}
	
huabu.prototype.保存=function(){//
		if(this.k=="id"){
			this.id.save();
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].save();
					}
				}
	}
huabu.prototype.恢复=function(){//
		if(this.k=="id"){
			this.id.restore();
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].restore();
					}
				}
	}

huabu.prototype.移动=function(x, y){//++ 
		if(this.k=="id"){
			this.id.translate(x, y);
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].translate(x, y);
					}
				}
	}

huabu.prototype.旋转=function(angle){//
		if(this.k=="id"){
			this.id.rotate(angle);
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].rotate(angle);
					}
				}
	}

huabu.prototype.缩放=function(x, y){//
		if(this.k=="id"){
			this.id.scale(x, y);
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].scale(x, y);
					}
				}
	}

huabu.prototype.变形=function(a, b, c, d, e, f){//
		if(this.k=="id"){
			this.id.transform(a, b, c, d, e, f);
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].transform(a, b, c, d, e, f);
					}
				}
	}
huabu.prototype.设置形变=function(a, b, c, d, e, f){
		if(this.k=="id"){
			this.id.setTransform(a, b, c, d, e, f);
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].setTransform(a, b, c, d, e, f);
					}
				}
	}
	
huabu.prototype.重置形变=function(){
		if(this.k=="id"){
			this.id.resetTransform();
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].resetTransform();
					}
				}
	}
huabu.prototype.绘制图片=function(image,x,y){//++
		if(this.k=="id"){
			this.id.drawImage(image,x,y);
			}else{
				for(var i=0;i<this.id.length;i++){
					this.id[i].drawImage(image,x,y);
					}
				}
	}
	
	window.画布=function(d){return new huabu(d)}
})();